<script type="text/javascript">
// 颁奖
$(function(){
  var timestap = {bet_count1} - 0;
  var betcount = {bet_count2} - 0;
  
  function countdown()
  {
    timediff = timestap;
	  secs = Math.floor(timediff);
    str = "总下注笔数(含走飞)：" + betcount + "<br>颁奖过帐计算中，预估 ";
    str += secs + " 秒完成，请稍候...... <br><hr /><div style='font-weight:900;color:red;'>★ 过帐预估完成的时间仅供参考之用 ★<br>★ 过帐作业尚未确实完成之前请勿执行任何选项或离开本颁奖视窗 ★</div>";
    $("div#msgCalc").addClass("msgBox-yellow").html(str);
    setTimeout("countdown()",1000)
    timestap-=1;
  	if (timestap < 0) {
  		timestap = 0;
  	}
  }
  $("input:button#btnCalc").click(function(){
    $(this).add("input:button#btnStopBetNow").attr("disabled","disabled");
    $.get("?op=admin&fp=xmlSetConf_3d&cmd=calc&id={id}&gametype={gametype}", function(data){
      if(data == "true"){
        $("#table1").css("display","none");
        countdown();
        $().chkLottoOK(); // 检查是否开奖完成
      }else{
        alert('error');
      }
    });
    
      
  });
  editType = {editType};
  if(editType == "true"){
    $("input").not("btnCalc").attr("disabled","disabled");
  
  }
  
  $("input:button#btnStopBetNow").click(function(){
    $.get("?op=admin&fp=xmlSetConf_3d&cmd=stop&gametype={gametype}&id={id}", function(data){
      if(data == "true"){
        window.top.mainFrame.location.replace("?op=admin&id={id}&cmd=edit&fp=lotto_3d&gametype={gametype}");
      }
    });
  });


  
  // 检查是否颁奖完毕
  $.fn.chkLottoOK = function(){ 
    $.ajax({
      type: 'POST',
      url: '?op=agent&fp=xmlCheckLotto_3d',
      dataType: 'json',
      data: 'id={id}&gametype={gametype}',
      success: function(rdata){
        if(rdata.state=="2"){
          window.top.mainFrame.location.replace("?op=admin&fp=calc_3d&mod={calc}&id={id}&gametype={gametype}"); 
        }else{
          setTimeout("$().chkLottoOK()",1000);   
        }
      }
    });
    
  
  };
  
});

</script>


<div id="editor">
<form method="post" action="op.php">
<input type="hidden" name="op" value="admin">
<input type="hidden" name="fp" value="lotto_3d">
<input type="hidden" name="cmd" value="{cmd}">
<input type="hidden" name="id" value="{id}">
<input type="hidden" name="gametype" value="{gametype}">

<table border="0" id="table1" cellspacing="0" cellpadding="4">
<tr>
<td valign="top"> 期 数 </td>
<td><input type="text" name="round" size="20" value="{round}" ></td>
</tr>

<tr>
<td valign="top">开奖日期</td>
<td><input type="text" name="open" id="open" size="20" value="{open}">
<a href="#" onclick="javascript:showCalendarById('open')"><img align=absmiddle src="class/calendar/calendar.png"  border=0 alt=""></a>
</td>
</tr>

<tr>
<td valign="top">开奖结果</td>
<td>
<table border="0" cellpadding="3" cellspacing="1" class="table0">
<tr align="center" class="td15">
<td>佰</td>
<td>拾</td>
<td>个</td>
</tr>
<tr class="td2">
<td><input type="text" name="n3" size="2" maxlength="2" value="{n3}" maxlength="1" /></td>
<td><input type="text" name="n2" size="2" maxlength="2" value="{n2}" maxlength="1" /></td>
<td><input type="text" name="n1" size="2" maxlength="2" value="{n1}" maxlength="1" /></td>
</tr>
</table>
</td>

</tr>

<tr>
<td colspan="2"><input type="submit" value="确定" name="B1" />&nbsp;
<input type="button" value="颁奖" {btnDisCalc} id="btnCalc" />&#12288;
<input type="reset" value="重新设定" name="B2" />
</td>
</tr>

<tr>
<td colspan="2">
<input {btnDisStopPlay} type=button value="全部停止下注" id="btnStopBetNow" onclick="this.disbled=disabled;">
</td>
</tr>
</table>
<div id="msgCalc" style='width:758px;font-size:14px;color:blue;' ></div>
</form>
</div>